package com.cuckoo.mall.thus.menuaccount.ticket;

import android.content.Context;

import com.bgn.baseframe.base.BasePresenterImpl;
import com.bgn.baseframe.network.HttpObserver;
import com.bgn.baseframe.network.bean.TDataBean;
import com.bgn.baseframe.utils.UiUtil;
import com.cuckoo.mall.R;
import com.cuckoo.mall.javabean.Ticket;
import com.cuckoo.mall.network.ApiManager;

import java.util.ArrayList;
import java.util.List;

/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class TicketPresenter extends BasePresenterImpl<TicketContract.View> implements TicketContract.Presenter {

    @Override
    public void getAllTicket() {
        ApiManager.getAllTickets().subscribe(new HttpObserver<TDataBean<List<Ticket>>>(mView) {
            @Override
            public void onSucceed(TDataBean<List<Ticket>> value) {
                mView.whenGetTicket(value.getData());
            }

            @Override
            public void onDefeat(TDataBean<List<Ticket>> value) {
                super.onDefeat(value);
                mView.initFaild(value.getError_msg());
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                mView.initFaild(UiUtil.getString(R.string.server_error));
            }
        });
    }
}
